<template>
<view class="page__bd page__bd_bottom">
	<custom-navbar bgColor="bg-white shadow" :isBack="true" :isHome="true">
		<block slot="backText">返回</block>
		<block slot="content">确认订单信息</block>
	</custom-navbar>
	<view class="daui-card daui-card__full zzui-card zzui-card-consignee" v-if="showExpress">
		<view class="daui-card__bd">
			<block v-if="consigneeInfo.id">
				<view class="daui-media daui-media_appmsg daui-media_xs" @click="openConsigneeList">
					<view class="daui-media__hd">
						<text class="iconfontzz icon-location text-gray text-xxl"></text>
					</view>
					<view class="daui-media__bd">
						<view>
							<text class="text-bold">{{consigneeInfo.realname}}</text>
							<text class="margin-lr-sm">{{consigneeInfo.mobile}}</text>
						</view>
						<view class="daui-media__work">
							<text class="daui-badge bg-green margin-right-xs" v-if="consigneeInfo.type_show">{{consigneeInfo.type_show}}</text>
							{{consigneeInfo.province}}{{consigneeInfo.city}}{{consigneeInfo.district}}{{consigneeInfo.address}}
						</view>
					</view>
					<view class="daui-media__ft vertical-middle">
						<text class="iconfontzz icon-pencil text-green"></text>
					</view>
				</view>
			</block>
			<block v-else>
				<view class="daui-cell">
					<view class="daui-cell__bd">
						<view class="daui-btn zzui-btn_primary daui-btn_block round" @click="openConsigneeAdd">
							<text class="iconfontzz icon-locationfill text-lg"></text>
							新建收货地址
						</view>
					</view>
				</view>
			</block>
		</view>
	</view>
	<form :report-submit="true" @submit="formSubmit">
		<block v-for="(item,index) in cartGroup" :key="index">
			<view class="daui-card daui-card__full zzui-card">
				<view class="daui-card__hd">
					{{item.shop_name}}
				</view>
				<view class="daui-card__bd">
					<block v-for="(itemCart,indexCart) in item.cartList" :key="indexCart">
						<view class="daui-media daui-media_appmsg daui-media_product" :hover="false" padding="0">
							<view class="daui-media__hd">
								<image class="daui-media__thumb" mode="scaleToFill" :src="itemCart.logo_show"></image>
							</view>
							<view class="daui-media__bd">
								<view class="daui-media__title">{{itemCart.prod_name}}</view>
								<view class="daui-media__desc" v-if="itemCart.subtitle">{{itemCart.subtitle}}</view>
								<view class="daui-media__work" v-if="itemCart.spec_isopen">
									{{itemCart.spec_name_1}}：<text>{{itemCart.spec_1}}</text>
									<text v-if="itemCart.spec_2">，{{itemCart.spec_name_2}}：{{itemCart.spec_2}}</text>
								</view>
								<view class="daui-media__desc" v-if="0">
									<text>品牌：{{itemCart.brand_name}}</text>
									<text class="margin-left">产地：{{itemCart.originplace}}</text>
								</view>
								<view class="daui-media__desc" v-if="0">
									包装方式：<text>{{itemCart.package}}</text>
									<text class="margin-left">重量：{{itemCart.weight}}kg</text>
								</view>
								<view class="daui-media__subbox margin-top-sm">
									<view class="daui-media__subbox_hd">
										<text class="text-price text-red text-lg">{{itemCart.final_price}}</text>
									</view>
									<view class="daui-media__subbox_bd">
										x{{itemCart.buy_num}}
									</view>
									<view class="daui-media__subbox_bd" v-if="0">
										<lxc-count @handleCount="changeCartNum" :key="countTimer" :index="itemCart.id" :value="itemCart.buy_num" :delayed="100" :customId="itemCart.id" :customIdTwo="0" costyle="1" defaultAddShow="1" :min="1"></lxc-count>
									</view>
								</view>
							</view>
						</view>
					</block>
				</view>
				<view class="daui-card__ft">
					<view class="daui-cell cart-statistics">
						<view class="daui-cell__bd text-right">
							<text class="cart-statistics-num">共{{item.shopProductNum}}件</text>
							<text class="margin-right-xs">小计：<text class="text-price text-red">{{item.shopProductFee}}</text></text>
							<text v-if="0">重量：<text>{{item.shopProductWeight}}kg</text></text>
						</view>
					</view>
				</view>
			</view>
		</block>
		
		<view class="daui-card daui-card__full zzui-card">
			<view class="daui-card__bd">
				<view class="daui-cell daui-cell_sm" v-if="goodDelivery == 1">
					<view class="daui-cell__hd">配送方式</view>
					<view class="daui-cell__bd daui-cell_primary">
						<radio-group class="daui-radio-group-inline" @change="deliveryChange">
							<label><radio value="4" checked="true" />线上核销</label>
						</radio-group>
					</view>
				</view>
				<view class="daui-cell daui-cell_sm" v-if="goodDelivery == 2">
					<view class="daui-cell__hd">配送方式</view>
					<view class="daui-cell__bd daui-cell_primary">
						<radio-group class="daui-radio-group-inline" @change="deliveryChange">
							<label v-if="isButtonSelfpickup"><radio value="1" :checked="defaultDelivery == 1" />自提</label>
							<label><radio value="2" :checked="defaultDelivery == 2" />快递</label>
						</radio-group>
					</view>
				</view>
			</view>
		</view>
		
		<view class="daui-card daui-card__full zzui-card" v-if="0 && showExpress">
			<view class="daui-card__bd">
				<view class="daui-cell daui-cell_sm daui-cell_access">
					<view class="daui-cell__hd">快递公司</view>
					<view class="daui-cell__bd"></view>
					<view class="daui-cell__ft">
						<picker :range="expresscompList" :range-key="'name'" :value="expresscompIndex" @change="expresscompChange">
							<view class="picker">
								{{expresscompList[expresscompIndex].name}}
							</view>
						</picker>
						<!--
						<radio-group class="daui-selout daui-selout-sm" @change="expresscompChange">
						<block v-for="(item, index) in expresscompList" :key="index">
							<view class="daui-selout-item">
								<label>
									<radio :value="item.id.toString()" />{{item.name}}
								</label>
							</view>
						</block>
						</radio-group>
						-->
					</view>
				</view>
				<view class="daui-cell daui-cell_sm" v-if="expresscompOtherOpen == 1">
					<view class="daui-cell__hd">其他公司</view>
					<view class="daui-cell__bd daui-cell_primary">
						<input type="text" name="expresscompOther" value="" placeholder="请备注物流公司名称" class="daui-input" />
					</view>
				</view>
				<view class="daui-cell daui-cell_sm" v-if="0">
					<view class="daui-cell__hd">保价方式</view>
					<view class="daui-cell__bd daui-cell_primary">
						<radio-group class="daui-radio-group-inline" @change="insureChange">
							<label><radio value="1" />我不投保</label>
							<label><radio value="2" />我要投保</label>
						</radio-group>
					</view>
				</view>
				<view class="daui-cell daui-cell_sm" v-if="insureUse == 2">
					<view class="daui-cell__hd">投保额度</view>
					<view class="daui-cell__bd daui-cell_primary">
						<input type="text" name="insureAmount" value="0" class="daui-input" />
						<view class="margin-top-xs text-red">重要提醒：我司将按照您投保的额度帮您此次商品购买保险， 依照各物流公司的收费标准。我司代为买方发物流，但运输途中的风险由买方承担。</view>
					</view>
				</view>
			</view>
		</view>
		
		<view class="daui-card daui-card__full" v-if="showSelfpickup">
			<view class="daui-card__hd">自提点</view>
			<view class="daui-card__bd">
				<radio-group class="radio-group-block" @change="selfpickupChange">
					<block v-for="(item, index) in selfpickupList" :key="index">
						<view class="daui-media daui-media_appmsg daui-media_user">
							<view class="daui-media__hd" v-if="0 && item.logo_show">
								<image :src="item.logo_show" mode="widthFix" class="daui-media__thumb"></image>
							</view>
							<view class="daui-media__bd">
								<view class="daui-media__title">自提点名称：{{item.name}}</view>
								<view class="daui-media__desc">联系人：{{item.contact}}</view>
								<view class="daui-media__desc">电话：{{item.phone}}</view>
								<view class="daui-media__desc">地址：{{item.address}}</view>
							</view>
							<view class="daui-media__ft">
								<radio :value="item.id.toString()" />
							</view>
						</view>
					</block>
				</radio-group>
			</view>
		</view>
		<view class="daui-card daui-card__full" v-if="showUserinfo">
			<view class="daui-card__hd">信息填写</view>
			<view class="daui-card__bd">
				<view class="daui-cell daui-cell_sm">
					<view class="daui-cell__hd daui-cell_mustdot">姓名</view>
					<view class="daui-cell__bd daui-cell_primary">
						<input type="text" name="realname" v-model="moonInfo.realname" placeholder="请输入姓名" class="daui-input" />
					</view>
				</view>
				<view class="daui-cell daui-cell_sm">
					<view class="daui-cell__hd daui-cell_mustdot">手机号码</view>
					<view class="daui-cell__bd daui-cell_primary">
						<input type="text" name="mobile" v-model="moonInfo.mobile" placeholder="请输入手机号码" class="daui-input" />
					</view>
				</view>
				<view class="daui-cell daui-cell_sm">
					<view class="daui-cell__hd">给商家留言</view>
					<view class="daui-cell__bd daui-cell_primary">
						<input type="text" name="leaveword" placeholder="请输入留言" class="daui-input" />
					</view>
				</view>
			</view>
		</view>
		<view class="daui-card" v-if="isLeavemessOpen == 1">
			<view class="daui-card__bd">
				<block v-for="(item, index) in leavemess_fields" :key="index">
					<view class="daui-cell daui-cell_sm J_user_wrap">
						<view class="daui-cell__hd">{{item.name}}</view>
						<view class="daui-cell__bd weui-cell_primary">
							<input type="text" v-model="leavemessInput[item.flag]" :placeholder="item.desc" class="daui-input" />
						</view>
					</view>
				</block>
			</view>
		</view>
		<view class="daui-card daui-card__full" v-if="configInfo.integral_isopen == 1">
			<view class="daui-card__bd">
				<view class="daui-cell daui-cell_sm daui-cell_access" @click="showIntegralPopup">
					<view class="daui-cell__hd"><text class="daui-cell-icon iconfontzz icon-jifen"></text>积分</view>
					<view class="daui-cell__bd daui-cell_primary"></view>
					<view class="daui-cell__ft text-primary">
						{{chooseIntegralBtnName}}
					</view>
				</view>
			</view>
		</view>
		<view class="daui-card daui-card__full" v-if="moonInfo.realbalance > 0">
			<view class="daui-card__bd">
				<view class="daui-cell daui-cell_sm daui-cell_access" @click="showBalancePopup">
					<view class="daui-cell__hd"><text class="daui-cell-icon iconfontzz icon-recharge"></text>余额</view>
					<view class="daui-cell__bd daui-cell_primary"></view>
					<view class="daui-cell__ft text-primary">
						{{chooseBalanceBtnName}}
					</view>
				</view>
			</view>
		</view>
		<view class="daui-card daui-card__full" v-if="redpacketCodeList.length > 0">
			<view class="daui-card__bd">
				<view class="daui-cell daui-cell_sm daui-cell_access" @click="showRedpacketPopup">
					<view class="daui-cell__hd"><text class="daui-cell-icon iconfontzz icon-redpacket"></text>红包</view>
					<view class="daui-cell__bd daui-cell_primary"></view>
					<view class="daui-cell__ft text-primary">
						<view v-if="chooseRedpacketBtnName">{{chooseRedpacketBtnName}}</view>
						<view class="daui-badge line-orange radius" v-if="chooseRedpacketName">{{chooseRedpacketName}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="daui-card daui-card__full" v-if="couponCodeList.length > 0">
			<view class="daui-card__bd">
				<view class="daui-cell daui-cell_sm daui-cell_access" @click="showCouponPopup">
					<view class="daui-cell__hd"><text class="daui-cell-icon iconfontzz icon-quan"></text>优惠券</view>
					<view class="daui-cell__bd daui-cell_primary"></view>
					<view class="daui-cell__ft text-primary">
						<view v-if="chooseCouponBtnName">{{chooseCouponBtnName}}</view>
						<view class="daui-badge line-orange radius" v-if="chooseCouponName">{{chooseCouponName}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="daui-card daui-card__full" v-if="configInfo.fullredu_isopen">
			<view class="daui-card__bd">
				<view class="daui-cell daui-cell_sm">
					<view class="daui-cell__hd">满减活动</view>
					<view class="daui-cell__bd">
						<radio-group class="daui-radio-group-inline" @change="fullreduChange">
							<label><radio value="-1" />不使用</label>
							<label v-for="(item,index) in fullreduList" :key="index"><radio :value="index.toString()" />{{item.name}}</label>
						</radio-group>
					</view>
				</view>
			</view>
		</view>
		<view class="daui-card daui-card__full" v-if="0">
			<view class="daui-card__bd">
				<view class="daui-cell daui-cell_sm daui-cell_access">
					<view class="daui-cell__hd">订单备注</view>
					<view class="daui-cell__bd"></view>
					<view class="daui-cell__ft" @tap="showleaveword">
						{{leavewordShow}}
					</view>
				</view>
			</view>
		</view>
		<view class="daui-card daui-card__full">
			<view class="daui-card__bd">
				<view class="daui-cell daui-cell_sm">
					<view class="daui-cell__hd">支付方式</view>
					<view class="daui-cell__bd daui-cell_primary">
						<radio-group class="daui-radio-group-inline" @change="payMethodChange">
							<label v-if="moonInfo.is_creditacc == 1"><radio value="credit" />信用支付</label>
							<label v-if="configInfo.is_online == 1"><radio value="online" />在线支付</label>
							<label v-if="configInfo.paymethod_bank == 1"><radio value="bank" :checked="true" />对公转账</label>
							<label v-if="configInfo.paymethod_wxpay == 1"><radio value="wxpay" />微信支付</label>
							<label v-if="configInfo.paymethod_balance == 1"><radio value="balance" />余额支付</label>
						</radio-group>
					</view>
				</view>
			</view>
		</view>
		<view class="daui-card daui-card__full">
			<view class="daui-card__bd">
				<view class="extension-list">
					<view class="daui-cell">
						<view class="daui-cell__hd">商品金额</view>
						<view class="daui-cell__bd">￥{{cartProductFee}}</view>
					</view>
					<view class="daui-cell">
						<view class="daui-cell__hd">运费金额</view>
						<view class="daui-cell__bd">{{cartDeliveryShow}}</view>
					</view>
					<view class="daui-cell" v-if="couponShow">
						<view class="daui-cell__hd">抵扣优惠券</view>
						<view class="daui-cell__bd">-￥{{cartCouponFee}}</view>
					</view>
					<view class="daui-cell" v-if="redpacketShow">
						<view class="daui-cell__hd">抵扣红包</view>
						<view class="daui-cell__bd">-￥{{cartRedpacketFee}}</view>
					</view>
					<view class="daui-cell" v-if="integralShow">
						<view class="daui-cell__hd">积分兑换</view>
						<view class="daui-cell__bd">-￥{{cartIntegralFee}}</view>
					</view>
					<view class="daui-cell" v-if="fullreduShow">
						<view class="daui-cell__hd">满减金额</view>
						<view class="daui-cell__bd">-￥{{cartFullreduFee}}</view>
					</view>
					<view class="daui-cell" v-if="balanceShow">
						<view class="daui-cell__hd">抵扣余额</view>
						<view class="daui-cell__bd">-￥{{cartBalanceFee}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="daui-cell daui-cell_agree">
			<view class="daui-cell__hd">
				<evan-checkbox v-model="agreementChecked" @change="doAgree" shape="square">阅读并同意</evan-checkbox>
			</view>
			<view class="daui-cell__bd">
				<text class="text-blue" @tap="showAgreement">《买方须知》</text>
			</view>
		</view>
		<view class="daui-tabbar daui-tabbar-cart daui-tabbar-fixed solid-top">
			<view class="daui-tabbar__bd daui-tabbar__price">
				实付款
				<text class="text-price text-lightred margin-left-xs">{{cartTotalFee}}</text>
			</view>
			<view class="daui-tabbar__hd daui-tabbar__submit" v-if="configInfo.order_eject">
				<button @click="showEjectPopup">提交订单</button>
			</view>
			<view class="daui-tabbar__ft" v-else>
				<button formType="submit" class="daui-btn daui-btn_danger daui-btn_sm round">提交订单</button>
			</view>
		</view>
		
		<!-- 结算弹窗提示 -->
		<uni-popup ref="ejectPopup">
			<view class="daui-dialog daui-dialog_sm">
				<view class="daui-dialog__bd" v-html="configInfo.order_eject">
				</view>
				<view class="daui-dialog__ft">
					<button class="daui-btn bg-red block" form-type="submit">提交订单</button>
				</view>
			</view>
		</uni-popup>
		
	</form>
	
	<!-- 协议弹出框 -->
	<uni-popup ref="agreementPopup" :type="popupType" :animation="false">
		<view class="daui-fullpopup">
			<view class="daui-fullpopup__bd daui-fullpopup__bd-padding bg-white">
				<scroll-view scroll-y="true" style="height: 100%;">
					<mp-html :content="agreementContent" lazy-load="true" :tag-style="tagStyle">协议详情展示</mp-html>
				</scroll-view>
			</view>
			<view class="daui-fullpopup__ft">
				<button class="daui-btn zzui-btn_primary daui-block" @click="doAgree">我已阅读并同意此协议</button>
			</view>
		</view>
	</uni-popup>
	
	<!-- 订单备注 -->
	<uni-popup ref="leavewordPopup" :type="popupType" :animation="false">
		<view class="daui-commpopup">
			<view class="daui-commpopup__hd">
				<view class="daui-cell">
					<view class="daui-cell__bd">订单备注</view>
					<view class="daui-cell__ft" @click="hideLeavewordPopup">
						<text class="iconfontzz icon-close"></text>
					</view>
				</view>
			</view>
			<view class="daui-commpopup__bd daui-commpopup__bd-padding bg-white">
				<textarea name="leaveword" v-model="leaveword" class="daui-textarea daui-textarea_blue" placeholder="给商家留言"></textarea>
				<button class="daui-btn zzui-btn_primary daui-block margin-top" @click="hideLeavewordPopup">确认</button>
			</view>
			<view class="daui-commpopup-close">
			</view>
		</view>
	</uni-popup>
	
	<!-- 积分抵扣弹出框 -->
	<uni-popup ref="integralPopup" :type="popupType" :animation="false">
		<view class="daui-commpopup">
			<view class="daui-commpopup__hd">
				<view class="daui-cell">
					<view class="daui-cell__bd">积分抵扣</view>
					<view class="daui-cell__ft" @click="hideIntegralPopup">
						<text class="iconfontzz icon-close"></text>
					</view>
				</view>
			</view>
			<view class="daui-commpopup__bd daui-commpopup__bd-padding bg-white">
				<view class="daui-alert daui-alert_danger">
					<view class="daui-alert__hd"></view>
					<view class="daui-alert__bd">我的积分：{{moonInfo.realintegral}}</view>
				</view>
				<scroll-view scroll-y style="height: 700rpx;">
					<radio-group class="radio-group-block" @change="integralChange">
						<view class="daui-cell">
							<view class="daui-cell__bd">
								不使用积分抵扣
							</view>
							<view class="daui-cell__ft"><radio value="-1" :checked="integralIndex == -1 ? true : false" /></view>
						</view>
						<view class="daui-cell" v-for="(item,index) in integralList" :key="index">
							<view class="daui-cell__bd">
								使用{{item.integral_num}}积分抵扣：<text class="text-price">{{item.deduct_fee}}</text>
							</view>
							<view class="daui-cell__ft"><radio :value="index.toString()" :checked="integralIndex == index ? true : false" /></view>
						</view>
					</radio-group>
				</scroll-view>
			</view>
		</view>
	</uni-popup>
	
	<!-- 余额抵扣弹出框 -->
	<uni-popup ref="balancePopup" :type="popupType" :animation="false">
		<view class="daui-commpopup">
			<view class="daui-commpopup__hd">
				<view class="daui-cell">
					<view class="daui-cell__bd">余额抵扣</view>
					<view class="daui-cell__ft" @click="hideBalancePopup">
						<text class="iconfontzz icon-close"></text>
					</view>
				</view>
			</view>
			<view class="daui-commpopup__bd daui-commpopup__bd-padding bg-white">
				<view class="daui-alert daui-alert_danger">
					<view class="daui-alert__hd"></view>
					<view class="daui-alert__bd">我的余额：{{moonInfo.realbalance}}</view>
				</view>
				<scroll-view scroll-y style="height: 700rpx;">
					<radio-group class="radio-group-block" @change="balanceChange">
						<view class="daui-cell">
							<view class="daui-cell__bd">
								不使用余额抵扣
							</view>
							<view class="daui-cell__ft"><radio value="-1" :checked="balanceIndex == -1 ? true : false" /></view>
						</view>
						<view class="daui-cell" v-for="(item,index) in balanceList" :key="index">
							<view class="daui-cell__bd">
								使用余额抵扣：<text class="text-price">{{item.balance_fee}}</text>
							</view>
							<view class="daui-cell__ft"><radio :value="index.toString()" :checked="balanceIndex == 1 ? true : false" /></view>
						</view>
					</radio-group>
				</scroll-view>
			</view>
		</view>
	</uni-popup>
	
	<!-- 红包弹出框 -->
	<uni-popup ref="redpacketPopup" type="bottom">
		<view class="daui-commpopup">
			<scroll-view scroll-y style="height: 700rpx;">
				<view class="redpacket-wrap">
					<view class="daui-cell not-use-tips" @click="chooseRedpacketCode(0, 0)">
						<view class="daui-cell__bd">
							不使用红包
						</view>
					</view>
					<view class="daui-cell redpacket-item" v-for="(item,index) in redpacketCodeList" :key="index">
						<view class="daui-cell__hd">
							<text class="unit">￥</text><text class="amount">{{item.real_amount}}</text>
						</view>
						<view class="daui-cell__bd">
							<view class="text-bold">
								{{item.redpacket_name}}
							</view>
							<view class="desc">
								{{item.limit_amount_appletshow}}
							</view>
							<view class="desc" v-if="0">
								限***部分商品使用
							</view>
							<view class="time">
								{{item.expire_time_appletshow}}
							</view>
							<view class="time">
								{{item.descrip}}
							</view>
						</view>
						<view class="daui-cell__ft" @click="chooseRedpacketCode(item.id, index)">
							<view class="redpacket-btn">立即使用</view>
						</view>
						<view class="coupon-wave-right"></view>
					</view>
				</view>
			</scroll-view>
			<view class="daui-commpopup-close">
				<text class="iconfontzz icon-roundclosefill" @click="hideRedpacketPopup"></text>
			</view>
		</view>
	</uni-popup>
	
	<!-- 优惠券弹出框 -->
	<uni-popup ref="couponPopup" type="bottom">
		<view class="daui-commpopup">
			<scroll-view scroll-y style="height: 700rpx;">
				<view class="coupon-wrap">
					<view class="daui-cell not-use-tips" @click="chooseCouponCode(0, 0)">
						<view class="daui-cell__bd">
							不使用优惠劵
						</view>
					</view>
					<view class="daui-cell coupon-item" v-for="(item,index) in couponCodeList" :key="index">
						<view class="daui-cell__hd" v-if="item.use_threshold == 4">
							<view class="type">
								包邮券
							</view>
						</view>
						<view class="daui-cell__hd" v-else-if="item.use_threshold == 2">
							<view class="amount"><text>{{item.real_discount_show}}</text>折</view>
							<view class="type">
								折扣券
							</view>
						</view>
						<view class="daui-cell__hd" v-else>
							<view class="amount"><text>{{item.real_amount}}</text>元</view>
							<view class="type">
								通用券
							</view>
						</view>
						<view class="daui-cell__bd">
							<view class="class">
								{{item.coupon_name}}
							</view>
							<view class="class2">
								{{item.limit_amount_appletshow}}
							</view>
							<view class="time">
								{{item.expire_time_appletshow}}
							</view>
							<view class="time">
								{{item.descrip}}
							</view>
						</view>
						<view class="daui-cell__ft" @click="chooseCouponCode(item.id, index)">
							<view class="tit">立即使用</view>
						</view>
						<view class="coupon-wave-right"></view>
					</view>
				</view>
			</scroll-view>
			<view class="daui-commpopup-close">
				<text class="iconfontzz icon-roundclosefill" @click="hideCouponPopup"></text>
			</view>
		</view>
	</uni-popup>
	
	<!--toast提示-->
	<daui-toast ref="toast"></daui-toast>
</view>
</template>

<script>
import http from "../../server/api-product.js";
import httpUpload from "../../server/api-upload.js";
import danceuiTool from '../../utils/danceuiTool';
import numberTool from '../../utils/numberTool';
import mpHtml from '@/components/mp-html/mp-html'
export default {
	components:{
		mpHtml
	},
	data() {
		return {
			Platform: this.Platform, //导航栏高度
			StatusBar: this.StatusBar, //导航栏高度
			CustomBar: this.CustomBar, //状态栏高度
			danceData: this.danceData, //配置数据
			tagStyle: {'img':'float:left'}, //html内容解析
			deliveryMode: 1,
			goodDelivery: 0,
			moonInfo: {},
			configInfo: {},
			tmplIds: [],
			isButtonSelfpickup: 0,
			defaultDelivery: 1,
			showSelfpickup: 1,
			showUserinfo: 0,
			showExpress: 0,
			isLeavemessOpen: 0,
			leavemess_fields: [],
			leavemessInput: {},
			popupType: 'bottom',
			agreementChecked: false,
			agreementContent: '',
			consigneeInfo: {},
			selfpickupId: 0,
			insureUse: 0,
			insureAmount: '',
			creditaccPay: 0,
			payMethod: 'bank',
			initMode: 0,
			firstDelivery: 0,
			initShid: 0,
			initPid: 0,
			initWhid: 0,
			initSpecId: 0,
			initBuyNum: 0,
			deductionGoldOpen: true,
			cartGroup: [],
			countTimer: 0,
			priceInfo: {},
			otherInfo: {},
			cartProductFee: 0,
			cartDeliveryFee: 0,
			cartDeliveryShow: '到付',
			cartCouponFee: 0,
			cartRedpacketFee: 0,
			cartIntegralFee: 0,
			cartFullreduFee: 0,
			cartBalanceFee: 0,
			cartTotalFee: 0,
			couponCodeList: [],
			couponCodeId: 0,
			chooseCouponBtnName: '选择优惠券',
			chooseCouponName: '',
			couponShow: false,
			redpacketCodeList: [],
			redpacketCodeId: 0,
			chooseRedpacketBtnName: '选择优惠券',
			chooseRedpacketName: '',
			redpacketShow: false,
			integralList: [],
			integralIndex: -1,
			deductIntegral: 0,
			integralShow: false,
			chooseIntegralBtnName: '',
			balanceList: [],
			balanceIndex: -1,
			deductBalance: 0,
			balanceShow: false,
			chooseBalanceBtnName: '',
			chooseRedpacketName: '',
			fullreduList: [],
			fullreduShow: false,
			imageIdsGroup: {},
			imageDataGroup: {
				idcard_front: [],
				idcard_reverse: [],
				half_photo: [],
				social_insurance: [],
			},
			leaveword: '',
			leavewordShow: '去填写',
			selfpickupList: [],
			expresscompList: [],
			expresscompIndex: 0,
			expresscompOtherOpen: 0,
			insufficient: false,
			orderId: 0
		}
	},
	onLoad(options) {
		console.log('onLoad的参数:', options);
		console.log('Platform:', this.Platform);
		this.initMode = options.initMode ? options.initMode : 1;
		this.firstDelivery = options.firstDelivery ? options.firstDelivery : 0;
		this.initShid = options.initShid ? options.initShid : 0;
		this.initPid = options.initPid ? options.initPid : 0;
		this.initWhid = options.initWhid ? options.initWhid : 0;
		this.initSpecId = options.initSpecId ? options.initSpecId : 0;
		this.initBuyNum = options.initBuyNum ? options.initBuyNum : 0;
		this.getData();
	},
	methods: {
		async getData(){ //请求并获取数据
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			var param = {
				platform: this.Platform,
				initMode: this.initMode,
				initShid: this.initShid,
				initPid: this.initPid,
				initWhid: this.initWhid,
				initSpecId: this.initSpecId,
				initBuyNum: this.initBuyNum
			};
			let ret = await http.orderPrepairMulti(this.$refs.toast, param, headers, 1);
			console.log('orderPrepair页面，获取到的数据：', ret);
			if(ret.code == 200){
				var retData = ret.data;
				this.configInfo = retData.configInfo;
				this.tmplIds = retData.tmplIds;
				this.consigneeInfo = retData.consigneeInfo;
				this.totalCartNum = retData.totalCartNum;
				this.cartGroup = retData.cartGroup;
				this.goodDelivery = retData.goodDelivery;
				this.isButtonSelfpickup = retData.isButtonSelfpickup;
				this.isLeavemessOpen = retData.isLeavemessOpen;
				this.otherInfo = retData.otherInfo;
				this.priceInfo = retData.priceInfo;
				console.log('相关价格数据：', retData.priceInfo);
				this.defaultDelivery = retData.defaultDelivery;
				this.firstDelivery = retData.defaultDelivery;
				console.log('默认配送方式defaultDelivery:', this.defaultDelivery);
				if(this.defaultDelivery == 1){ //默认自提
					this.cartProductFee = parseFloat(this.priceInfo.productFee);
					this.cartDeliveryFee = 0;
					//this.cartIntegralFee = parseFloat(this.priceInfo.integralFee);
					//this.cartTotalFee = parseFloat(this.priceInfo.productFee) - parseFloat(this.priceInfo.integralFee);
					this.cartTotalFee = this.priceInfo.totalFee;
					this.showSelfpickup = 1;
					this.showExpress = 0;
					if(this.isLeavemessOpen == 1){
						this.showUserinfo = 0;
					}else{
						this.showUserinfo = 1;
					}
					this.deliveryMode = 1;
				}else if(this.defaultDelivery == 2){ //默认快递
					this.cartProductFee = parseFloat(this.priceInfo.productFee);
					this.cartDeliveryFee = parseFloat(this.priceInfo.deliveryFee);
					this.cartGoldFee = parseFloat(this.priceInfo.integralFee);
					//this.cartTotalFee = parseFloat(this.priceInfo.productFee) + parseFloat(this.priceInfo.deliveryFee) - parseFloat(this.priceInfo.integralFee);
					this.cartTotalFee = this.priceInfo.totalFee;
					this.showSelfpickup = 0;
					this.showExpress = 1;
					this.showUserinfo = 0;
					this.deliveryMode = 2;
				}else{
					this.cartProductFee = parseFloat(this.priceInfo.productFee);
					this.cartDeliveryFee = parseFloat(this.priceInfo.deliveryFee);
					this.cartGoldFee = parseFloat(this.priceInfo.integralFee);
					this.cartTotalFee = this.priceInfo.totalFee;
					this.showSelfpickup = 0;
					this.showExpress = 0;
					this.showUserinfo = 1;
					this.deliveryMode = 4;
				}
				this.selfpickupList = retData.selfpickupList;
				if(retData.expresscompList){
					var defaultList = new Array();
					defaultList.push({id:0, name:'请选择'});
					this.expresscompList = [...defaultList, ...retData.expresscompList];
				}else{
					this.expresscompList = new Array();
				}
				this.moonInfo = retData.moonInfo;
				this.leavemess_fields = retData.leavemess_fields;
				for(var i in retData.leavemess_fields){
					var flag = retData.leavemess_fields[i].flag;
					var defaultValue = retData.leavemess_fields[i].defaultValue;
					this.leavemessInput[flag] = defaultValue;
				}
				this.integralList = retData.integralList;
				this.balanceList = retData.balanceList;
				this.couponCodeList = retData.couponCodeList;
				this.chooseCouponBtnName = retData.couponCodeList.length+'张可用';
				this.redpacketCodeList = retData.redpacketCodeList;
				this.chooseRedpacketBtnName = retData.redpacketCodeList.length+'张可用';
				this.fullreduList = retData.fullreduList;
				this.chooseIntegralBtnName = '最高可抵扣'+retData.priceInfo.maxIntegralFee+'元，去选择';
				this.chooseBalanceBtnName = '最高可抵扣'+retData.priceInfo.maxBalanceFee+'元，去选择';
			}
		},
		async showAgreement(){ //请求并获取数据
			let ret = await http.explain(this.$refs.toast, {'type': 'shoppingterms'});
			var retData = ret.data;
			this.popupType = 'bottom';
			this.$refs.agreementPopup.open();
			this.agreementContent = retData.content;
		},
		doAgree(){
			this.$refs.agreementPopup.close()
			this.agreementChecked = true;
		},
		//富文本展示相关
		ready(e) {
			console.log('ready', e);
			// console.log('api: getText', this.$refs.article.getText());
			//console.log('imgList', this.$refs.article.imgList);
		},
		imgtap(e) {
			console.log('imgtap', e);
		},
		linkpress(e) {
			console.log('linkpress', e);
		},
		error(e) {
			console.error(e);
		},
		deliveryChange(e){
			console.log('选择的值:', e.target.value)
			var productFee = this.priceInfo.productFee;
			var deliveryFee = this.priceInfo.deliveryFee;
			var couponFee = this.priceInfo.couponFee;
			var redpacketFee = this.priceInfo.redpacketFee;
			var integralFee = this.priceInfo.integralFee;
			var productFee = parseFloat(productFee);
			var deliveryFee = parseFloat(deliveryFee);
			var couponFee = parseFloat(couponFee);
			var redpacketFee = parseFloat(redpacketFee);
			var integralFee = parseFloat(integralFee);
			console.log('商品金额:', productFee, '运费金额:', deliveryFee, '优惠券抵扣金额:', couponFee, '红包抵扣金额:', redpacketFee, '积分抵扣金额:', integralFee);
			if(e.target.value == 1){
				this.cartDeliveryFee = 0;
				this.cartTotalFee = productFee;
				this.showSelfpickup = 1;
				if(this.isLeavemessOpen == 1){
					this.showUserinfo = 0;
				}else{
					this.showUserinfo = 1;
				}
				this.showExpress = 0;
				this.firstDelivery = 1;
			}else if(e.target.value == 2){
				this.cartDeliveryFee = deliveryFee;
				this.cartTotalFee = productFee + deliveryFee;
				this.showSelfpickup = 0;
				this.showUserinfo = 0;
				this.showExpress = 1;
				this.firstDelivery = 2;
			}
			this.deliveryMode = e.target.value;
		},
		selfpickupChange(e){
			console.log('选择的值:', e.target.value);
			this.selfpickupId = e.target.value;
		},
		openConsigneeList() {
			uni.navigateTo({
				url: '/pagesA/mine/myConsignee?initMode='+this.initMode+'&firstDelivery='+this.firstDelivery+'&initShid='+this.initShid+'&initPid='+this.initPid+'&initWhid='+this.initWhid+'&initSpecId='+this.initSpecId+'&initBuyNum='+this.initBuyNum
			})
		},
		openConsigneeAdd() {
			uni.navigateTo({
				url: '/pagesA/mine/myConsigneeAdd?initMode='+this.initMode+'&firstDelivery='+this.firstDelivery+'&initShid='+this.initShid+'&initPid='+this.initPid+'&initWhid='+this.initWhid+'&initSpecId='+this.initSpecId+'&initBuyNum='+this.initBuyNum
			})
		},
		insureChange(e){
			console.log('选择的值:', e.target.value);
			this.insureUse = e.target.value;
		},
		expresscompChange(e){
			console.log('选择的值:', e.target.value);
			this.expresscompIndex = e.target.value;
			var expresscompInfo = this.expresscompList[this.expresscompIndex];
			console.log('快递公司信息:', expresscompInfo);
			this.expresscompId = expresscompInfo.id;
			var expresscompType = expresscompInfo.type;
			//this.expresscompId = e.target.value;
			// var expresscompType = 0;
			// for(var i in this.expresscompList){
			// 	if(this.expresscompList[i].id == this.expresscompId){
			// 		expresscompType = this.expresscompList[i].type;
			// 	}
			// }
			if(expresscompType == 4){
				this.expresscompOtherOpen = 1;
			}else{
				this.expresscompOtherOpen = 0;
			}
		},
		payMethodChange(e){
			console.log('选择的值:', e.target.value);
			this.payMethod = e.target.value;
		},
		/**
		 * 加入以及更新购物车
		 */
		async changeCartNum(realvalue, index, customId, customIdTwo){
			console.log('changeCartNum操作,realvalue:'+realvalue+';index:'+index+';customId:'+customId+';customIdTwo:'+customIdTwo);
			var that = this;
			if(this.initPid){
				const token = uni.getStorageSync('token');
				var headers = {"Authorization":"Bearer "+token};
				var param = {
					initShid: this.initShid,
					initWhid: this.initWhid,
					initPid: this.initPid,
					initSpecId: this.initSpecId,
					initBuyNum: realvalue
				};
				let ret = await http.doBuyVerify(this.$refs.toast, param, headers);
				if(ret.code == 200){
					var retData = ret.data;
					console.log('doBuyVerify操作正确,获取到的数据:', retData);
					this.initBuyNum = realvalue;
					this.cartTotalFee = retData.siteCartFee; //更新购物车总数量
					// this.priceInfo = retData.priceInfo;
					// this.defaultDelivery = retData.defaultDelivery;
					// if(this.firstDelivery){
					// 	this.defaultDelivery = this.firstDelivery;
					// }
					// if(retData.defaultDelivery == 1){ //默认自提
					// 	this.cartProductFee = this.priceInfo.productFee;
					// 	this.cartDeliveryFee = 0;
					// 	this.cartGoldFee = this.priceInfo.integralFee;
					// 	this.cartTotalFee = this.priceInfo.productFee - this.priceInfo.integralFee;
					// 	this.showSelfpickup = 1;
					// 	this.showExpress = 0;
					// 	this.deliveryMode = 1;
					// 	this.defaultDelivery = 1;
					// }else if(retData.defaultDelivery == 2){ //默认快递
					// 	this.cartProductFee = this.priceInfo.productFee;
					// 	this.cartDeliveryFee = this.priceInfo.deliveryFee;
					// 	this.cartGoldFee = this.priceInfo.integralFee;
					// 	this.cartTotalFee = this.priceInfo.productFee + this.priceInfo.deliveryFee - this.priceInfo.integralFee;
					// 	this.showSelfpickup = 0;
					// 	this.showExpress = 1;
					// 	this.deliveryMode = 2;
					// 	this.defaultDelivery = 2;
					// }else{
					// 	this.cartProductFee = this.priceInfo.productFee;
					// 	this.cartDeliveryFee = this.priceInfo.deliveryFee;
					// 	this.cartGoldFee = this.priceInfo.integralFee;
					// 	this.cartTotalFee = this.priceInfo.productFee + this.priceInfo.deliveryFee - this.priceInfo.integralFee;
					// 	this.showSelfpickup = 0;
					// 	this.showSelfpickup = 0;
					// 	this.showExpress = 0;
					// 	this.deliveryMode = 4;
					// 	this.defaultDelivery = 4;
					// }
				}else{
					var retData = ret.data;
					console.log('doBuyVerify操作错误,获取到的数据:', retData);
					// var tmpCart = this.cartList[index];
					// tmpCart.buy_num = retData.buyNum;
					// tmpCart.prod_name = 'gggg';
					// console.log('tmpCart:', tmpCart);
					// this.$set(this.cartList, index, tmpCart); //渲染到视图层
					this.cartList[index].buy_num = retData.buyNum;
					this.countTimer = new Date().getTime(); //重新加载子组件
				}
			}else{
				this.numberValue = realvalue;
				// this.dataList[e.index].buyNum = e.value
				// setTimeout(() => {
				// 	this.calcHandle()
				// }, 0)
				const token = uni.getStorageSync('token');
				let headers = {"Authorization":"Bearer "+token};
				var param = {
					cartId: customId,
					buyOrAdd: 1,
					initBuyNum: realvalue
				};
				let ret = await http.doAddAndUpdateCart(this.$refs.toast, param, headers);
				console.log('doAddAndUpdateCart操作,请求数据:', ret);
				if(ret.code == 200){
					var retData = ret.data;
					this.cartBuyNum = retData.cartBuyNum; //更新购物车总数量
					this.cartTotalFee = retData.siteCartFee; //更新购物车总数量
					//更新购物车总金额
					// var productFee = retData.shopCartFee;
					// var deliveryFee = this.priceInfo.deliveryFee;
					// var couponFee = this.priceInfo.couponFee;
					// var redpacketFee = this.priceInfo.redpacketFee;
					// var integralFee = this.priceInfo.integralFee;
					// var productFee = parseFloat(productFee);
					// var deliveryFee = parseFloat(deliveryFee);
					// var couponFee = parseFloat(couponFee);
					// var redpacketFee = parseFloat(redpacketFee);
					// var integralFee = parseFloat(integralFee);
					// console.log('商品金额:', productFee, '运费金额:', deliveryFee, '优惠券抵扣金额:', couponFee, '红包抵扣金额:', redpacketFee, '积分抵扣金额:', integralFee);
					// this.cartProductFee = productFee;
					// this.cartDeliveryFee = deliveryFee;
					// this.cartTotalFee = productFee + deliveryFee - integralFee;
				}
			}
		},
		showIntegralPopup(e) { //积分抵扣弹出
			this.$refs.integralPopup.open();
		},
		integralChange(e) { //积分抵扣选择
			console.log('积分抵扣选择change，携带值为', e.target.value);
			this.integralIndex = e.target.value;
			this.deductIntegral = this.integralList[this.integralIndex].integral_num;
			let deductFee = this.integralList[this.integralIndex].deduct_fee;
			console.log('积分是：', this.deductIntegral, '积分抵扣金额：', deductFee);
			if(this.deductIntegral > 0){
				this.cartIntegralFee = deductFee; //改变的初始值
				this.integralShow = true;
				this.chooseIntegralBtnName = '使用'+this.deductIntegral+'积分，抵扣'+deductFee+'元';
			}else{
				this.cartIntegralFee = 0;
				this.integralShow = false;
				this.chooseIntegralBtnName = '最高可抵扣'+this.priceInfo.maxIntegralFee+'元，去选择';
			}
			this.cartTotalFee = this.calTotalFee(this.cartProductFee, this.cartDeliveryFee, this.cartCouponFee, this.cartRedpacketFee, this.cartIntegralFee, this.cartBalanceFee);
			this.$refs.integralPopup.close();
		},
		hideIntegralPopup: function() {
			this.$refs.integralPopup.close();
		},
		showBalancePopup(e) { //余额抵扣弹出
			this.$refs.balancePopup.open();
		},
		balanceChange(e) { //余额抵扣选择
			console.log('余额抵扣选择change，携带值为', e.target.value);
			this.balanceIndex = e.target.value;
			let balanceFee = this.balanceList[this.balanceIndex].balance_fee;
			console.log('余额是：', balanceFee);
			if(balanceFee > 0){
				this.cartBalanceFee = balanceFee; //改变的初始值
				this.balanceShow = true;
				this.chooseBalanceBtnName = '抵扣'+balanceFee+'元';
			}else{
				this.cartBalanceFee = 0; //改变的初始值
				this.balanceShow = false;
				this.chooseBalanceBtnName = '最高可抵扣'+balanceFee+'元，去选择';
			}
			this.cartTotalFee = this.calTotalFee(this.cartProductFee, this.cartDeliveryFee, this.cartCouponFee, this.cartRedpacketFee, this.cartIntegralFee, this.cartBalanceFee);
			this.$refs.balancePopup.close();
		},
		hideBalancePopup: function() {
			this.$refs.balancePopup.close();
		},
		showCouponPopup(e) { //优惠券选择
			this.$refs.couponPopup.open();
		},
		hideCouponPopup: function() {
			this.$refs.couponPopup.close();
		},
		chooseCouponCode(id, index) {
			var productFee = parseFloat(this.cartProductFee);
			var deliveryFee = parseFloat(this.cartDeliveryFee);
			var redpacketFee = parseFloat(this.cartRedpacketFee);
			var integralFee = parseFloat(this.cartIntegralFee);
			var fullreduFee = parseFloat(this.cartFullreduFee);
			var balanceFee = parseFloat(this.cartBalanceFee);
			if(id == 0){
				this.couponCodeId = 0;
				var couponFee = 0;
				this.chooseCouponBtnName = this.couponCodeList.length+'张可用';
				this.chooseCouponName = '';
				this.couponShow = false;
				this.cartDeliveryShow = '到付';
				this.cartTotalFee = productFee + deliveryFee - couponFee - redpacketFee - integralFee - balanceFee;
			}else{
				this.couponCodeId = id;
				var couponCodeInfo = this.couponCodeList[index];
				console.log('选择的优惠券码信息:', couponCodeInfo);
				this.chooseCouponBtnName = '';
				this.chooseCouponName = '已选'+couponCodeInfo.coupon_name;
				this.couponShow = true;
				if(couponCodeInfo.use_threshold == 4){ //使用门槛,包邮券
					this.cartDeliveryShow = '包邮';
					var couponFee = 0;
				}else if(couponCodeInfo.use_threshold == 2){ //使用门槛,折扣
					this.cartDeliveryShow = '到付';
					var realDiscount = numberTool.FloatMul(couponCodeInfo.real_discount, 0.01);
					var couponFee = numberTool.FloatSub(productFee, numberTool.FloatMul(productFee, realDiscount));
					console.log('折扣：', realDiscount, '；抵扣金额：', couponFee);
				}else{ //使用门槛,满减
					this.cartDeliveryShow = '到付';
					var couponFee = parseFloat(couponCodeInfo.real_amount);
				}
			}
			this.cartCouponFee = couponFee; //改变的初始值
			var totalFee = 0;
			totalFee = numberTool.FloatAdd(productFee, deliveryFee);
			console.log('总金额:', totalFee);
			totalFee = numberTool.FloatSub(totalFee, couponFee);
			console.log('总金额:', totalFee);
			console.log('红包金额:', redpacketFee);
			totalFee = numberTool.FloatSub(totalFee, redpacketFee);
			console.log('总金额:', totalFee);
			totalFee = numberTool.FloatSub(totalFee, integralFee);
			console.log('总金额:', totalFee);
			totalFee = numberTool.FloatSub(totalFee, fullreduFee);
			console.log('总金额:', totalFee);
			totalFee = numberTool.FloatSub(totalFee, balanceFee);
			console.log('总金额:', totalFee);
			this.cartTotalFee = totalFee;
			console.log('商品金额:', productFee, '运费金额:', deliveryFee, '优惠券抵扣金额:', couponFee, '红包抵扣金额:', redpacketFee, '积分抵扣金额:', integralFee, '余额抵扣金额:', balanceFee, '总金额:', totalFee);
			this.$refs.couponPopup.close();
		},
		showRedpacketPopup(e){ //红包选择
			this.$refs.redpacketPopup.open();
		},
		hideRedpacketPopup: function() {
			this.$refs.redpacketPopup.close();
		},
		chooseRedpacketCode(id, index){
			if(id == 0){
				this.redpacketCodeId = 0;
				var redpacketFee = 0;
				this.chooseRedpacketBtnName = this.redpacketCodeList.length+'张可用';
				this.chooseRedpacketName = '';
				this.redpacketShow = true;
			}else{
				this.redpacketCodeId = id;
				var redpacketCodeInfo = this.redpacketCodeList[index];
				console.log('选择的红包码信息:', redpacketCodeInfo);
				var redpacketFee = parseFloat(redpacketCodeInfo.real_amount);
				this.chooseRedpacketBtnName = '';
				this.chooseRedpacketName = '已选'+redpacketCodeInfo.redpacket_name;
				this.redpacketShow = true;
			}
			this.$refs.redpacketPopup.close();
			this.cartRedpacketFee = redpacketFee; //改变的初始值
			this.cartTotalFee = this.calTotalFee(this.cartProductFee, this.cartDeliveryFee, this.cartCouponFee, this.cartRedpacketFee, this.cartIntegralFee, this.cartBalanceFee);
		},
		fullreduChange(e){
			console.log('选择的值:', e.target.value);
			var productFee = parseFloat(this.cartProductFee);
			var deliveryFee = parseFloat(this.cartDeliveryFee);
			var couponFee = parseFloat(this.cartCouponFee);
			var redpacketFee = parseFloat(this.cartRedpacketFee);
			var integralFee = parseFloat(this.cartIntegralFee);
			var balanceFee = parseFloat(this.cartBalanceFee);
			var totalFee = 0;
			if(e.target.value == -1){
				this.fullreduId = 0;
				var fullreduFee = 0;
				this.fullreduShow = false;
				totalFee = numberTool.FloatAdd(productFee, deliveryFee);
				totalFee = numberTool.FloatSub(totalFee, couponFee);
				totalFee = numberTool.FloatSub(totalFee, redpacketFee);
				totalFee = numberTool.FloatSub(totalFee, integralFee);
				totalFee = numberTool.FloatSub(totalFee, fullreduFee);
				totalFee = numberTool.FloatSub(totalFee, balanceFee);
			}else{
				var index = e.target.value;
				var fullreduInfo = this.fullreduList[index];
				console.log('选择的满减活动信息:', fullreduInfo);
				this.fullreduId = fullreduInfo.id;
				this.fullreduShow = true;
				if(fullreduInfo.use_threshold == 1){ //使用门槛
					var fullreduFee = parseFloat(fullreduInfo.real_amount);
					totalFee = numberTool.FloatAdd(productFee, deliveryFee);
					totalFee = numberTool.FloatSub(totalFee, couponFee);
					totalFee = numberTool.FloatSub(totalFee, redpacketFee);
					totalFee = numberTool.FloatSub(totalFee, integralFee);
					totalFee = numberTool.FloatSub(totalFee, fullreduFee);
					totalFee = numberTool.FloatSub(totalFee, balanceFee);
				}else if(fullreduInfo.use_threshold == 2){
					var couponDiscount = parseFloat(fullreduInfo.real_discount);
					var realDiscount = numberTool.FloatMul(fullreduInfo.real_discount, 0.01);
					var fullreduFee = numberTool.FloatSub(productFee, numberTool.FloatMul(productFee, realDiscount));
					totalFee = numberTool.FloatAdd(productFee, deliveryFee);
					totalFee = numberTool.FloatSub(totalFee, couponFee);
					totalFee = numberTool.FloatSub(totalFee, redpacketFee);
					totalFee = numberTool.FloatSub(totalFee, integralFee);
					totalFee = numberTool.FloatSub(totalFee, fullreduFee);
					totalFee = numberTool.FloatSub(totalFee, balanceFee);
				}
			}
			this.cartFullreduFee = fullreduFee;
			this.cartTotalFee = totalFee;
			console.log('商品金额:', productFee, '运费金额:', deliveryFee, '优惠券抵扣金额:', couponFee, '红包抵扣金额:', redpacketFee, '积分抵扣金额:', integralFee, '余额抵扣金额:', balanceFee, '总金额:', this.cartTotalFee);
		},
		calTotalFee(productFee, deliveryFee, couponFee, redpacketFee, integralFee, balanceFee){
			console.log('商品金额:', productFee, '运费金额:', deliveryFee, '优惠券抵扣金额:', couponFee, '红包抵扣金额:', redpacketFee, '积分抵扣金额:', integralFee, '余额抵扣金额:', balanceFee);
			productFee = parseFloat(productFee);
			deliveryFee = parseFloat(deliveryFee);
			couponFee = parseFloat(couponFee);
			redpacketFee = parseFloat(redpacketFee);
			integralFee = parseFloat(integralFee);
			balanceFee = parseFloat(balanceFee);
			productFee = productFee * 100;
			deliveryFee = deliveryFee * 100;
			couponFee = couponFee * 100;
			redpacketFee = redpacketFee * 100;
			integralFee = integralFee * 100;
			balanceFee = balanceFee * 100;
			var totalFee = productFee + deliveryFee - couponFee - redpacketFee - integralFee - balanceFee;
			//console.log('总金额1:', totalFee);
			totalFee = numberTool.FloatDiv(totalFee, 100);
			//console.log('总金额2:', totalFee);
			return totalFee;
		},
		showleaveword() {
			this.popupType = 'bottom';
			this.$refs.leavewordPopup.open();
		},
		hideLeavewordPopup() {
			this.$refs.leavewordPopup.close();
			this.leavewordShow = this.leaveword.slice(0, 10);
		},
		singleChooseSuccess(tempFilePaths, custom) { //图片上传逻辑
			console.log('singleChooseSuccess:', tempFilePaths, ';自定义参数：', custom);
			/****************
			以下代码是自定义上传逻辑，仅供参考
			***************/
			this.singleImgUpload(tempFilePaths, custom);
			/*******************************/
		},
		singleImgUpload(tempFilePaths, custom) {
			uni.showLoading({
				title: '上传中'
			});
			setTimeout(function () {
				uni.hideLoading();
			}, 1000);
			console.log('上传图片操作,tempFilePaths:', tempFilePaths, ';自定义变量custom:', custom);
			let uploadImgs = [];
			tempFilePaths.forEach((item, index) => {
				uploadImgs.push(new Promise((resolve, reject) => {
					//console.log(index, item)
					this.singleImgUploadTwo(item, custom);
				}))
			})
			Promise.all(uploadImgs) //执行所有需请求的接口
				.then((results) => {
					uni.hideLoading();
				})
				.catch((res, object) => {
					uni.hideLoading();
				});
		},
		async singleImgUploadTwo(filepath, custom) {
			//获取用户登陆信息
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			var param = {
				field_flag: custom
			}
			let ret = await httpUpload.orderSingleUpload(this.$refs.toast, filepath, headers, param);
			console.log('orderSingleUpload操作，获取到的数据：', ret);
			if(ret.code == 200){
				var retData = ret.data;
				var tmpArr = [retData.id];
				this.imageIdsGroup[custom] = tmpArr;
				var tmpArr = [retData.picurl_show];
				this.imageDataGroup[custom] = tmpArr;
				//this.imageIdsSingle.push(retData.id);
				//this.imageDataSingle.push(retData.picurl_show);
				console.log('上传成功后imageIds:', this.imageIdsGroup, ';imageData:', this.imageDataGroup);
			}
		},
		async singleImgDelete(uploadLists, index, custom) { //图片删除逻辑
			var id = this.imageIdsGroup[custom][index];
			console.log('uploadLists:', uploadLists, '待删除的图片索引:', index, '待删除的图片id:', id, ';自定义变量custom:', custom);
			if(id){
				//获取用户登陆信息
				const token = uni.getStorageSync('token');
				let headers = {"Authorization":"Bearer "+token};
				var param = {
					id: id
				}
				let ret = await http.orderDeleteImg(this.$refs.toast, param, headers, {});
				console.log('orderDeleteImg操作，获取到的数据：', ret);
				if(ret.code == 200){
					var retData = ret.data;
					this.imageIdsGroup[custom] = [];
					this.imageDataGroup[custom] = [];
					//this.imageIdsSingle.splice(index, 1);
					//this.imageDataSingle.splice(index, 1);
					console.log('删除图片后imageIds:', this.imageIdsGroup, 'imageData:', this.imageDataGroup);
				}
			}else{
				this.imageData.splice(index, 1)
			}
		},
		showEjectPopup(e){ //结算弹窗提示
			this.$refs.ejectPopup.open();
		},
		async formSubmit(e){ //表单提交事件
			var that = this;
			//获取用户登陆信息
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			var param = {
				platform: this.Platform,
				deliveryMode: this.deliveryMode,
				selfpickupId: this.selfpickupId,
				expresscompId: this.expresscompId,
				expresscompOther: e.detail.value.expresscompOther,
				insureUse: this.insureUse,
				insureAmount: e.detail.value.insureAmount,
				payMethod: this.payMethod,
				realname: e.detail.value.realname,
				mobile: e.detail.value.mobile,
				social_company: e.detail.value.social_company,
				leaveword: this.leaveword,
				agree: this.agreementChecked==true?1:0,
				initMode: this.initMode,
				initShid: this.initShid,
				initPid: this.initPid,
				initWhid: this.initWhid,
				initSpecId: this.initSpecId,
				initBuyNum: this.initBuyNum,
				deductIntegral: this.deductIntegral,
				deductBalanceFee: this.cartBalanceFee,
				leavemessInput: this.leavemessInput,
				couponCodeId: this.couponCodeId,
				redpacketCodeId: this.redpacketCodeId,
				fullreduId: this.fullreduId
			};
			console.log('imageIdsGroup:', this.imageIdsGroup);
			param.imageIdsGroup = this.imageIdsGroup;
			let ret = await http.orderSubmitMulti(this.$refs.toast, param, headers);
			console.log('订单提交操作orderSubmit,返回数据：', ret);
			if(ret.code == 200){
				var retData = ret.data;
				this.orderId = retData.orderId;
				//#ifdef MP-WEIXIN
				console.log('订阅消息tmplIds:', this.tmplIds);
				if(this.tmplIds.length > 0){
					uni.requestSubscribeMessage({
						tmplIds: this.tmplIds,
						success (res) {
							console.log('订阅消息成功,res:', res)
							//danceuiTool.dealLink(retData.page_flag, retData.page_data);
							that.afterSubmit(retData);
						}
					})
				}else{
					//danceuiTool.dealLink(retData.page_flag, retData.page_data);
					that.afterSubmit(retData);
				}
				//#endif
				//#ifndef MP-WEIXIN
				//danceuiTool.dealLink(retData.page_flag, retData.page_data);
				that.afterSubmit(retData);
				//#endif
			}
		},
		afterSubmit(retData) {
			//#ifdef H5
			if(this.payMethod == 'wxpay'){
				window.location.href = this.danceData.webURL+'/index.php?s=/mobmall/wxpay/doJsapi/orderId/'+this.orderId;
			}else if(this.payMethod == 'alipay'){
				window.location.href = this.danceData.webURL+'/index.php?s=/mobmall/alipayTradeWap/doAlipay/orderId/'+this.orderId;
			}else{
				setTimeout(() => {
					danceuiTool.dealLink(retData.page_flag, retData.page_data);
				}, 500);
			}
			//#endif
			
			//#ifdef MP-WEIXIN
			if(this.payMethod == 'wxpay'){
				this.doWxpay();
			}else{
				setTimeout(() => {
					danceuiTool.dealLink(retData.page_flag, retData.page_data);
				}, 500);
			}
			//#endif
			
			//#ifdef APP-PLUS
			if(payMethod == 'wxpay'){
				this.weixinLoginAppPlus();
			}else if(payMethod == 'alipay'){
				this.doAlipayForAppPlus();
			}else{
				danceuiTool.dealLink(retData.page_flag, retData.page_data);
			}
			//#endif
		},
		//#ifdef MP-WEIXIN
		async doWxpay(){
			var that = this;
			//获取用户登陆信息
			const token = uni.getStorageSync('token');
			let headers = {"Authorization":"Bearer "+token};
			var platform = 'mp-weixin';
			var param = {
				orderId: this.orderId,
				platform: platform
			}
			let ret = await http.wxpayDoJsapi(this.$refs.toast, param, headers);
			console.log('wxpayDoJsapi,请求数据：', ret);
			if(ret.code == 200){
				var retData = ret.data;
				uni.requestPayment({
					timeStamp: retData.jsApiParameters.timeStamp,
					nonceStr: retData.jsApiParameters.nonceStr,
					package: retData.jsApiParameters.package,
					signType: 'MD5',
					paySign: retData.jsApiParameters.paySign,
					success: (res) => {
						danceuiTool.showToast(this.$refs.toast, '支付成功');
						uni.redirectTo({
							url: '/pages/order/myOrderDetail?orderId='+that.orderId
						})
					},
					fail: (res) => {
						uni.showModal({
							//content: "支付失败,原因为: " + res.errMsg,
							content: "支付不成功，请到订单页面重新支付",
							showCancel: false,
							success: function (res) {
								uni.redirectTo({
									url: '/pages/order/myOrderDetail?orderId='+that.orderId
								})
							}
						})
					},
					complete: () => {
						this.loading = false;
					}
				})
			}else{
				uni.showModal({
					content: "支付不成功，请到订单页面重新支付",
					showCancel: false,
					success: function (res) {
						uni.redirectTo({
							url: '/pages/order/myOrderDetail?orderId='+that.orderId
						})
					}
				})
			}
		},
		//#endif
	}
}
</script>

<style>
.zzui-card-consignee:after{content:" ";position: absolute;width: 100%;height: 8rpx;left: 0;bottom: 0;background: url("https://www.danceui.com/appres/order/consignee.png");}

.cart-statistics{font-size: 28rpx;}
.cart-statistics .cart-statistics-num{color: #8799a3;margin-right: 10rpx;font-size: 24rpx;}

.not-use-tips{color: #f7b240;font-size: 16px;text-align: center;}

/*扩展价格*/
.extension-list{background-color:#ffffeb;border:1px solid #ffe2cf;border-radius:5px;margin: 20rpx;}
.extension-list .daui-cell:before{border-top:1px dashed #ffe2cf}
.extension-list .daui-cell__bd{color:#ff8f44;text-align: right;}
</style>